package smn.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import smn.domain.MyUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import smn.dao.manager.IUserManager;

/**
* User: Abdulaziz
* Date: 1/8/12
* Time: 10:49 AM
*/
@Controller
@RequestMapping("/myuser")
public class MyUserController extends AbstractController{
    @Autowired
    IUserManager userManager;

    @InitBinder
	public void initBinder(WebDataBinder binder) {
//        User user = new User();
//        user.setFirstName("Aziz");
//        user.setUsername("aziz");
//        userManager.persist(user);
	}

//    @Transactional
    @RequestMapping(value = "/user", method = RequestMethod.GET)
    public ModelAndView account(){
        MyUser user = new MyUser();
        user.setFirstName("Aziz");
        user.setUsername("aziz");
        userManager.persist(user);
        return new ModelAndView("index.jsp");
    }
}
